#ifndef EASYMSGCALLBACK_H
#define EASYMSGCALLBACK_H
#include "libeasymsg_global.h"
#include <tr1/memory>
#include <tr1/shared_ptr.h>
#include <tr1/functional>
namespace EM {
    class EasyMsg;
}
namespace EasyMsgImp{

class LIBEASYMSGSHARED_EXPORT EasyMsgCallback
{
public:
    EasyMsgCallback(std::tr1::function<void(EM::EasyMsg*)> callbackfunc);
    void call(EM::EasyMsg* msg);
    template<typename _Func, typename _HostObj>
    static std::tr1::shared_ptr<EasyMsgCallback> CreateCallback(_Func func, _HostObj* hostObj){
        return std::tr1::shared_ptr<EasyMsgCallback>(
                    new EasyMsgCallback(std::tr1::bind(func, hostObj, std::tr1::placeholders::_1)));
    }
    template<typename _Func>
    static std::tr1::shared_ptr<EasyMsgCallback> CreateCallback(_Func func){
        return std::tr1::shared_ptr<EasyMsgCallback>(
                    new EasyMsgCallback(std::tr1::bind(func, std::tr1::placeholders::_1)));
    }

private:
    std::tr1::function<void(EM::EasyMsg*)> m_callback;
};

}
#endif // EASYMSGCALLBACK_H
